package com.wyu.servlet;

import com.wyu.service.YGService;
import com.wyu.service.YGServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/DeleteYgServlet")
public class DeleteYgServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String ygh = request.getParameter("ygh");
        System.out.println("要删除的工号:"+ygh);
        YGService xservice = new YGServiceImpl();
        int i = xservice.deletebyGh(ygh);
        System.out.println("删除"+i+"个员工");
        response.sendRedirect("ygxx.jsp");
        request.getSession().setAttribute("Deletemessage","删除员工成功");

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
